<? if ($c = stack('name')) {

	$d = component_data($c); 
	$s = component_settings($c);
	
startScript('jquery.history'); ?><script type="text/javascript">jQuery(function($){
	
log = (window.console && window.console.log) || function () {};

window.core = new (function($, window) {
	
	var $list = $(".photo-view ul"), prev = '';
	
	function chosen(url) {
		var $target, href, url = url.split("#").pop();
		
		if (($target = $list.find('a[href$="/' + url + '"]')).length) {
			return {hash:url, url:$target.attr("href"), a:$target, changed:false};
		} else {
			$target = $list.find('a');
			href = $target.attr("href");
			return {hash:href.split("/").pop(), url:href, a:$target, changed:true};
		}
	}

	this.route = function(url) {
		var target = chosen(url);
		
		if (target.changed)
			location.href = location.href.replace(/#.*/,"") + "#" + target.hash;
		else {
			if (target.hash != prev) {

				$('#big_photo').attr('src', target.url);
				target.a.parents('ul').find('a').removeClass('current');
				target.a.addClass('current');
				$list.scrollTo('.current img', 250, { offset: -1 });
				
				prev = target.hash;
			}
		}
	}
	
	this.changeHash = function($target) {
		var hash = $target.attr("href").split("/").pop();
		prev = hash;
		location.href = location.href.replace(/#.*/,"") + "#" + hash;
	}
	
})(jQuery, window);

$(window).hashchange(function(e){ window.core.route(location.hash) }).hashchange();

});</script><? endScript(); 
	
//debug($d);


?><div class="frame">
	<div class="photo-view">
		 <div class="photo">
			  <img id="big_photo" src="img/blank.gif" alt=""/>
			  <div class="nav-inner">
					<a href="#" id="prev_photo"><?=tc('Предыдущая')?></a>
					<a href="#" id="next_photo"><?=tc('Следующая')?></a>
					<a href="<?=_transformURL($CURRENT->url, array('remove_param' => 'see'))?>"><img src="/img/grid.gif" alt=""/> <?=tc('Все фото')?></a>
			  </div>
		 </div>
		 <ul><?
		 
			foreach($d['objects'] as $im) {
				?><li><a href="<?="$s[path]/$im[fn]"?>"><img src="<?="$s[path]/$im[tn]"?>" alt=""/></a></li><?
			}
		?></ul>
	</div>
</div><?

 
	unstack();
}